//
//  CZBaseTableViewController.swift
//  微博08
//
//  Created by mac on 16/2/28.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit

class CZBaseTableViewController: UITableViewController, CZVisitorViewDelegate{
    
    var userLogin = false

    override func viewDidLoad() {
        userLogin ? super.viewDidLoad() : setupVisitorView()

        
    }

    //设置访客视图
    func setupVisitorView()
    {
        self.view = visitorView
        
        //设置代理
        visitorView.visitorViewDelegate = self
        
        
        //CZHomeController.self 和 OC里面[CZHomeController class]一样
        if self is CZHomeController
        {
            visitorView.iconViewRotation()
        }
        else if(self is CZMessageController)
        {
            visitorView.setupVisitorView("visitordiscover_image_message", message: "信息信息信息信息信息信息信息信息信息信息信息信息信息")
        }
        else if(self is CZDiscoverController)
        {
            visitorView.setupVisitorView("visitordiscover_image_message", message: "发现发现发现发现发现发现发现发现发现发现发现发现发现发现")
        }
        else if(self is CZProflieController)
        {
            visitorView.setupVisitorView("visitordiscover_image_profile", message: "我我我我我我我我我我我我我我我我我我我我我")
        }
        
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewRegisterButtonClick")
        navigationItem.leftBarButtonItem?.tintColor = UIColor.orangeColor()
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewLoginButtonClick" )
        navigationItem.rightBarButtonItem?.tintColor = UIColor.orangeColor()
        
    }
    
    //实现代理方法
    func visitorViewRegisterButtonClick() {
        print("注册")
    }
    
    func visitorViewLoginButtonClick() {
        print("登陆")
    }
    
    
    //懒加载
    lazy var visitorView :CZVisitorView = CZVisitorView()

}
